<template>
<form @submit="gosubmit">
    <view class="modle">
        <view class="modle_title">提现金额</view>
        <view class="modle_input_border">
            <text style="float:left">￥</text>
            <input class="modle_input" name="withdraw" type="digit">
        </view>
        <view class="modle_btm_title">可提现金额 ¥{{detail.balance?detail.balance:0}}</view>
        <button class="btn" form-type="submit">申请提现</button>
    </view>
</form>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
      detail: ""
    };
  },

  components: {},
  props: {},
  onLoad: function (a) {
    var t = this;
    app.globalData.util.request({
      url: "entry/wxapp/Api",
      data: {
        m: "monai_market",
        r: "store.getBalance",
        uid: wx.getStorageSync("uid")
      },
      success: function (a) {
        a.data.data && t.setData({
          detail: a.data.data
        });
      }
    });
  },
  methods: {
    gosubmit: function (t) {
      var e = this;
      t.detail.value.withdraw || app.globalData.util.message({
        title: "金额不能为空"
      }), t.detail.value.withdraw > e.detail.balance && app.globalData.util.message({
        title: "不能大于余额"
      }), app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "store.addWithdraw",
          uid: wx.getStorageSync("uid"),
          balance: t.detail.value.withdraw
        },
        success: function (a) {
          1 == a.data.data && (app.globalData.util.message({
            title: "申请成功"
          }), e.setData({
            detail: {
              balance: e.detail.balance - t.detail.value.withdraw
            }
          }));
        }
      });
    }
  }
};
</script>
<style>
@import "./tixian.css";
</style>